package homework015.utils;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;


public class TcpUtils {
    public static void sendTo(String ip, int port, String message) throws IOException {
        //1,创建一个Socket对象
        Socket socket = new Socket(ip,port);

        //2.获取一个IO流开始写数据
        OutputStream os = socket.getOutputStream();
        os.write(message.getBytes());

        //3.释放资源
        os.close();
        socket.close();
    }
}
